package me.zhengjie.modules.personPayoutQuery.rest;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.swagger.annotations.Api;
import lombok.RequiredArgsConstructor;
import me.zhengjie.modules.businessRevoke.service.BusinessRevokeService;
import me.zhengjie.modules.fileupload.domain.dto.ElectronicMaterialFileDetailVOCriteria;
import me.zhengjie.modules.logs.domain.BusinessLog;
import me.zhengjie.modules.personPayoutQuery.domain.dto.PersonPayoutQueryCriteria;
import me.zhengjie.modules.personPayoutQuery.service.PersonPayoutQueryService;
import me.zhengjie.tool.ValidateUtil;
import me.zhengjie.utils.PageResult;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.io.IOException;
import java.util.Map;

@RestController
@RequiredArgsConstructor
@Api(tags = "api")
@RequestMapping("/api/personPayoutQuery")
public class PersonPayoutQueryController {

    @Resource
    private PersonPayoutQueryService personPayoutQueryService;

    /**
     * 查询人员支出信息
     */
    @GetMapping("/list")
    public ResponseEntity<PageResult<PersonPayoutQueryCriteria>> list(PersonPayoutQueryCriteria criteria){
//        ValidateUtil.isEmptyThrowException(criteria.getQueryType(),"查询类型");
        Page<Object> page = new Page<>(criteria.getPage(), criteria.getSize());
        ObjectMapper objectMapper = new ObjectMapper();
        Map<String, Object> param = objectMapper.convertValue(criteria, Map.class);
        return new ResponseEntity<>(personPayoutQueryService.queryList(param,page), HttpStatus.OK);
    }
}
